import re

# group by brackets

# step1: create a regex in a format.
phone_number_regex = re.compile(r'(\d\d\d)-(\d\d\d-\d\d\d\d)')
# step2: entity matching regex; if the search is successful, it returns a string.
result = phone_number_regex.search('My phone number is 414-555-0192')
# getting all items by groups()
print("The result is ", result.groups())
area_code, main_code = result.groups()
print("The areaCode is "+area_code+", the mainCode is "+main_code)
# get all items by subscript
print("The areaCode is "+result.group(1)+", the mainCode is "+result.group(2))
print("The phone number is "+result.group(0))
print("The phone number is "+result.group())
